package com.student.liu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.student.liu.entity.User;
import org.apache.ibatis.annotations.*;

/**
 * 用户类 Mapper
 */
@Mapper
public interface IUserMapper extends BaseMapper<User> {

    @Insert("insert into user values(default,#{username},MD5(CONCAT(#{username},#{password})),#{nickname},#{sex},now(),#{usable})")
    @Options(
            keyProperty = "id",
            useGeneratedKeys = true
    )
    int insertUser(User user);


    @Update("UPDATE user SET `password` = MD5(CONCAT(#{username},#{password})) WHERE username = #{username};")
    int updateCook(User user);

    @Select("SELECT COUNT(*) FROM `user` where `password` =  MD5(CONCAT(#{username},#{password})) and user.username = #{username};")
    int getByIdSelectPassword(User user);
}
